// 结论：面向对象设计应该采用指针对象
package main

func main() {
	s := NewStu(0, "")
	println(s.age) // 0
	s.upt1(1)      // 更新对象变量失败
	println(s.age) // 0
	s.upt2(2)
	println(s.age) // 0

	sp := NewStuPoint(0, "")
	println(sp.age) // 0
	sp.upt1(1)      // 更新对象变量成功
	println(sp.age) // 1
	sp.upt2(2)
	println(sp.age) // 2
}

type Stu struct {
	name string
	age  int
}

func NewStu(num int, name string) Stu {
	return Stu{
		name: name,
		age:  num,
	}
}

func (s Stu) upt1(num int) {
	s.age = num
}

func (s Stu) upt2(num int) {
	s.age = num
}

type StuPoint struct {
	name string
	age  int
}

func NewStuPoint(num int, name string) *StuPoint {
	return &StuPoint{
		name: name,
		age:  num,
	}
}

func (s *StuPoint) upt1(num int) {
	s.age = num
}

func (s *StuPoint) upt2(num int) {
	s.age = num
}
